import { defineConfig } from 'vite'
import path from "path";
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import { resolve } from "path"
export default defineConfig({

  plugins: [vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    
  ],
  resolve:{
    alias:{
      '@': path.resolve(__dirname, './src')
    }
  },
  css: {
    // 预处理器配置项
    preprocessorOptions: {
      scss: {
        additionalData: `@import '@/assets/css/variables.scss';`,
      },
    },
  },
  server: {				// ← ← ← ← ← ←
    host: true,
    proxy: {
     '/api': {
        //获取数据的服务器地址设置
        target: 'http://sph-api.atguigu.cn/',
        //需要代理跨域
        changeOrigin: true,
        //路径重写
        rewrite: (path) => path.replace(/^\/api/, ''),
      }
    }
  }	
})
